package com.br.semperparata.components.gui;

import java.awt.Font;
import java.util.List;
import java.util.Vector;

import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class Table extends JScrollPane {
	private static final long serialVersionUID = 1L;
	
	private JTable table = null;
	private List<String> columnNames = null;
	private List<List<Object>> data = null;
	
	public Table(List<String> columnNames, List<List<Object>> data) {
		super();
		this.columnNames = columnNames;
		this.data = data;
		
		this.table = new JTable();
		DefaultTableModel model = (DefaultTableModel)table.getModel();
		
		if (columnNames != null) {
			model.setColumnIdentifiers(new Vector<String>(columnNames));
		}
	
		if (data != null) {
			for (List<Object> rowData: data) {
				model.addRow(new Vector<Object>(rowData));
			}
		}
		
		this.setViewportView(table);
	}
	
	public void setTableFont(Font font) {
		this.table.setFont(font);
	}
	
	public void setHeaderFont(Font font) {
		this.table.getTableHeader().setFont(font);
	}
	
	public void setFonts(Font font) {
		setTableFont(font);
		setHeaderFont(font);
	}

}
